<?php

class CController {
	protected $_model;
	protected $_view;
	public function __construct() {
		$model = 'C'.ucfirst(CONTROLLER_NAME).'Model';
		if (file_exists(APP_PATH.'/model/'.$model.'.php')) {			
			$this->_model = new $model();
		}
		$this->_view = new CView();
	}
	public function message($message, $type = 0, $redirect_url = '') {
		if ('' === $redirect_url) {
			$redirect_url = $_SERVER['HTTP_REFERER'];
		}
		include APP_PATH . '/view/message.php';
	}
	public function url($controller, $method = 'index', $params = array()) {
		$params['c'] = $controller;
		$params['m'] = $method;
		return '?'.http_build_query($params);
	}
	public function redirection() {
		header('Location: index.php');
	}
}
